<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>JINMEI NOW System</title>
	<link rel="stylesheet" href="<%=request.getContextPath()%>/public/css/styles.css" />
	<link rel="stylesheet" href="<%=request.getContextPath()%>/public/css/simple.css" />
	<script type="text/javascript" src="<%=request.getContextPath()%>/public/jquery-ui-1.10.3.custom/js/jquery-1.9.1.js"></script>
	<script type="text/javascript">
		$(document).ready(
			function(){
				if ($('#abselectflag').val() == "0") {
					// 点击A班checkbox
					$('#borderedshell tr').find('td input[type=checkbox]:first').each(function() {
						$(this).bind('click', function(event) {
							var curval = $(this).is(":checked");
							var nextval = $(this).parent().next().children().is(":checked");
							if (curval == true && nextval == true) {
								var atypename = $('.darkblueodd th:eq(4)').html();
								var btypename = $('.darkblueodd th:eq(5)').html();
								alert("员工不能同时出勤" + atypename + "和" + btypename + "，请重新选择！");	
								$(this).attr("checked", !curval);
							}
						});
					});
					// 点击B班checkbox
					$('#borderedshell tr').find('td input[type=checkbox]:eq(1)').each(function() {
						$(this).bind('click', function(event) {
							var curval = $(this).is(":checked");
							var preval = $(this).parent().prev().children().is(":checked");
							if (curval == true && preval == true) {
								var atypename = $('.darkblueodd th:eq(4)').html();
								var btypename = $('.darkblueodd th:eq(5)').html();
								alert("员工不能同时出勤" + atypename + "和" + btypename + "，请重新选择！");	
								$(this).attr("checked", !curval);
							}
						});
					});
				}
				// 点击是否在岗checkbox
				$('#borderedshell tr').find('td input[type=checkbox]:eq(3)').each(function() {
					$(this).bind('click', function(event) {
						$(this).parent().parent().toggleClass("grayodd");
						//var curval = $(this).is(":checked");
						//$(this).parent().siblings().find('input[type=checkbox]').each(function() {
						//	$(this).attr("disabled", curval);
						//	$(this).attr("checked", false);
						//});
					});
				});
				// 是否在岗相关初始化
				$('#borderedshell tr').find('td input[type=checkbox]:eq(3)').each(function() {
					var curval = $(this).is(":checked");
					if (curval == true) {
						$(this).parent().parent().addClass("grayodd");
						//$(this).parent().siblings().find('input[type=checkbox]').each(function() {
						//	$(this).attr("disabled", curval);
						//	$(this).attr("checked", false);
						//});
					}
				});
				// 员工号失去焦点
				$('input[type=text]:first')
					.bind('blur', function(event) {
						var reg = /^[A-Za-z0-9]*$/;
						var value = $(this).val();
						if (!reg.test(value)) {
							$(this).css("background-color","#FFD9EC");
						}
					})
					.bind('focus', function(event) {
						$(this).css("background-color","#ffffff");
					});
				
				// sumbit检验
				$('form').removeAttr('onsubmit').bind('submit', function(event) {
					var valid = true;
					var element = $('input[type=text]:first');
					var reg = /^[A-Za-z0-9]*$/;
					var value = element.val();
					if (!reg.test(value)) {
						element.css("background-color","#FFD9EC");
						valid = false;
					}
					return valid;
				});
			}
		);

 	</script>
</head>
<body>
	<div id="document">	
			<div id="head">
				<table cellspacing="0" cellpadding="0" border="0" width="100%">
					<tr valign="top">
						<td>
							<!--<a href="#"><img src="../images/monogram.gif" alt="" width="213" height="57" /></a>-->
						</td>
						<td valign="middle">
							<div id="util">								
								<table cellspacing="0" cellpadding="0" border="0">
									<tr valign="middle">
										<td>用户：<s:property value="username"/></td>
										<td>&nbsp;&nbsp;</td>
										<td><a href="logout">退出</a></td>	
									</tr>
								</table>
					  		</div>				
						</td>
					</tr>
				</table>
			</div>
			<div id="nav1">
				<table cellspacing="0" cellpadding="0" border="0">
					<tr valign="middle">
						<td id="searchCell"></td>
						<td><img src="<%=request.getContextPath()%>/public/images/nav1Link.gif" alt="" width="9" height="8" />
							<a href="getWorkScheduleByDate?user_sessionid=<s:property value='%{user_sessionid}'/>">排班管理</a>
						</td>
						<td><img src="<%=request.getContextPath()%>/public/images/nav1Link.gif" alt="" width="9" height="8" /><a href="passwordSettingAction?user_sessionid=<s:property value='%{user_sessionid}'/>">密码设置</a></td>
						<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
					</tr>
			    </table>
			</div>
			<table border="0" cellpadding="0" cellspacing="0">
				<tr valign="top">
					<td id="navCell">
						<div  id="nav2">
							<ul class="breadcrumb">
								<li><a href="#">排班作业</a></li>
							</ul>
							<ul class="navitemList">
								<li><a href="wssetting?user_sessionid=<s:property value='%{user_sessionid}'/>">班表设置</a></li>
								<li><a href="getWorkScheduleByDate?user_sessionid=<s:property value='%{user_sessionid}'/>">出勤排班表管理</a></li>					
							</ul>
						</div>
					</td>
					<td id="mainCell">
						<h2 id="pageTitle" class="mainTitle">添加/更改值班员工</h2>
						<s:form >
							<table width="784" border="0" cellspacing="1">
								<tr>
									<td colspan="7" width="77%"></td>
									<td width="11%">值班日期</td>
									<td width="11%">
										<s:property value="%{workDate}"/>
										<s:hidden name="workDate" value="%{workDate}"/>
									</td>
								</tr>
								<tr>
									<td colspan="9"></td>	
								</tr>
								<tr>
									<td width="11%">员工号:</td>
									<td width="11%">
										<s:textfield name="employeeId" value="%{employeeId}" theme="simple"></s:textfield>
									</td>
									<td width="11%"></td>
									<td width="11%">员工姓名:</td>
									<td width="11%">
										<s:textfield name="employeeName" value="%{employeeName}" theme="simple"></s:textfield>
									</td>
									<td width="11%"></td>
									<td width="11%">
										<div><s:submit type="button" value="query" label="查询" style="width:80"
     					  						cssClass="Submit" theme="simple" action="getwsdbyempoyee"/>
     									</div>
									</td>
									<td colspan="2" width="22%"></td>
								</tr>
								<tr>
									<td colspan="9"></td>	
								</tr>
							</table>
					 
							<table id="borderedshell" width="784" cellspacing="1" cellpadding="0">
								<tbody>
									<tr class="darkblueodd" valign="top">
										<!--  th class="whitezi" width="60">ID</th-->
										<th class="whitezi" width="70">员工号</th>
										<th class="whitezi" width="120">姓名</th>
										<th class="whitezi" width="70">性别</th>
										<s:iterator value="workingtypes" status="stat">
											<th class="whitezi" width="70"><s:property value="%{descr}"/>班</th>
										</s:iterator>
										<th class="whitezi" width="70">不在岗</th>
									</tr>
									<s:iterator value="resultList" status="stat">
										<tr class="odd">
											<!--  td>
												<div align="left"><s:property value="#stat.count"/></div>
											</td-->
											<td>
												<div align="left"><s:property value="fnumber"/></div>
												<s:hidden name="resultList[%{#stat.index}].fnumber" value="%{fnumber}"/>
												<s:hidden name="resultList[%{#stat.index}].fid" value="%{fid}"/>
											</td>
											<td>
												<div align="left"><s:property value="fname"/></div>
												<s:hidden name="resultList[%{#stat.index}].fname" value="%{fname}"/>
											</td>
											<td>
												<div align="left"><s:property value="fsex"/></div>
												<s:hidden name="resultList[%{#stat.index}].fsex" value="%{fsex}"/>
											</td>
									
											<td><s:checkbox name="resultList[%{#stat.index}].isWorkingTypeA" value="%{isWorkingTypeA}" theme="simple"></s:checkbox></td>
											<td><s:checkbox name="resultList[%{#stat.index}].isWorkingTypeB" value="%{isWorkingTypeB}" theme="simple"></s:checkbox></td>
											<td><s:checkbox name="resultList[%{#stat.index}].isWorkingTypeC" value="%{isWorkingTypeC}" theme="simple"></s:checkbox></td>
											<td><s:checkbox name="resultList[%{#stat.index}].isNotOnDuty" value="%{isNotOnDuty}" theme="simple"></s:checkbox></td>
										</tr>
									</s:iterator>
								</tbody>
							 </table>
	 						<p> </p>
	 						<table width="784" cellspacing="0" cellpadding="0" border="0">
								<tr>
									<!-- td><input name="submit" style="width:80" type="button" class="Submit" value="确认" /></td-->
									<td width="90%"></td>
									<td align="center">
										<s:submit type="button" value="queryall" label="确认" style="width:80"
     					 						 cssClass="Submit" theme="simple"
     					  						onclick="return true;" action="updateallwsd"/>
     								</td>
								</tr>
							 </table>
							 <p> </p>
	 						<s:hidden name="user_sessionid" value="%{user_sessionid}"></s:hidden>
	 						<s:hidden id="abselectflag" name="abselectflag" value="%{abselectflag}"></s:hidden>
						</s:form>
					</td>
				</tr>
		  </table>	
			<div id="foot">
				<p>Copyright JINMEINOW  2013</p>
			</div>
		</div>
</body>
</html>